﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace RootMotion
{
	// Token: 0x020000F6 RID: 246
	public static class LayerMaskExtensions
	{
		// Token: 0x06000700 RID: 1792 RVA: 0x000067B4 File Offset: 0x000049B4
		public static bool Contains(LayerMask mask, int layer)
		{
			return mask == (mask | 1 << layer);
		}

		// Token: 0x06000701 RID: 1793 RVA: 0x000067CB File Offset: 0x000049CB
		public static LayerMask Create(params string[] layerNames)
		{
			return LayerMaskExtensions.NamesToMask(layerNames);
		}

		// Token: 0x06000702 RID: 1794 RVA: 0x000067D3 File Offset: 0x000049D3
		public static LayerMask Create(params int[] layerNumbers)
		{
			return LayerMaskExtensions.LayerNumbersToMask(layerNumbers);
		}

		// Token: 0x06000703 RID: 1795 RVA: 0x0003DB70 File Offset: 0x0003BD70
		public static LayerMask NamesToMask(params string[] layerNames)
		{
			LayerMask layerMask = 0;
			foreach (string layerName in layerNames)
			{
				layerMask |= 1 << LayerMask.NameToLayer(layerName);
			}
			return layerMask;
		}

		// Token: 0x06000704 RID: 1796 RVA: 0x0003DBBC File Offset: 0x0003BDBC
		public static LayerMask LayerNumbersToMask(params int[] layerNumbers)
		{
			LayerMask layerMask = 0;
			foreach (int num in layerNumbers)
			{
				layerMask |= 1 << num;
			}
			return layerMask;
		}

		// Token: 0x06000705 RID: 1797 RVA: 0x000067DB File Offset: 0x000049DB
		public static LayerMask Inverse(this LayerMask original)
		{
			return ~original;
		}

		// Token: 0x06000706 RID: 1798 RVA: 0x000067E9 File Offset: 0x000049E9
		public static LayerMask AddToMask(this LayerMask original, params string[] layerNames)
		{
			return original | LayerMaskExtensions.NamesToMask(layerNames);
		}

		// Token: 0x06000707 RID: 1799 RVA: 0x0003DC04 File Offset: 0x0003BE04
		public static LayerMask RemoveFromMask(this LayerMask original, params string[] layerNames)
		{
			LayerMask mask = ~original;
			return ~(mask | LayerMaskExtensions.NamesToMask(layerNames));
		}

		// Token: 0x06000708 RID: 1800 RVA: 0x0003DC38 File Offset: 0x0003BE38
		public static string[] MaskToNames(this LayerMask original)
		{
			List<string> list = new List<string>();
			for (int i = 0; i < 32; i++)
			{
				int num = 1 << i;
				if ((original & num) == num)
				{
					string text = LayerMask.LayerToName(i);
					if (!string.IsNullOrEmpty(text))
					{
						list.Add(text);
					}
				}
			}
			return list.ToArray();
		}

		// Token: 0x06000709 RID: 1801 RVA: 0x0003DC94 File Offset: 0x0003BE94
		public static int[] MaskToNumbers(this LayerMask original)
		{
			List<int> list = new List<int>();
			for (int i = 0; i < 32; i++)
			{
				int num = 1 << i;
				if ((original & num) == num)
				{
					list.Add(i);
				}
			}
			return list.ToArray();
		}

		// Token: 0x0600070A RID: 1802 RVA: 0x00006802 File Offset: 0x00004A02
		public static string MaskToString(this LayerMask original)
		{
			return original.MaskToString(", ");
		}

		// Token: 0x0600070B RID: 1803 RVA: 0x0000680F File Offset: 0x00004A0F
		public static string MaskToString(this LayerMask original, string delimiter)
		{
			return string.Join(delimiter, original.MaskToNames());
		}
	}
}
